var flatten = function (root) {
    let list = []
    function fast(node) {
        if (!node) return;
        list.push(node)
        fast(node.left)
        fast(node.right)
    }
    fast(root)
    for (let i = 1; i < list.length; i++) {
        let pre = list[i - 1], cur = list[i]
        pre.left = null
        pre.right = cur
    }
};

